package com.example.leero.graduation.adapter;

import android.content.Context;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.leero.graduation.R;
import com.example.leero.graduation.Util.DateUtil;
import com.example.leero.graduation.Util.ImageLoader;
import com.example.leero.graduation.Util.StringUtil;
import com.example.leero.graduation.model.Comment;
import com.zhy.adapter.recyclerview.CommonAdapter;
import com.zhy.adapter.recyclerview.base.ViewHolder;

import java.util.List;

/**
 * Created by Leero on 2017-4-26.
 */

public class ActDetailAdapter extends CommonAdapter<Comment> {
    private Context context;

    public ActDetailAdapter(Context context, int layoutId, List<Comment> datas) {
        super(context, layoutId, datas);
        this.context = context;
    }

    @Override
    protected void convert(ViewHolder holder, Comment comment, int position) {
        ImageView avatar = holder.getView(R.id.iv_avatar);
        TextView userName = holder.getView(R.id.user_name);
        TextView commentTime = holder.getView(R.id.comment_time);
        TextView content = holder.getView(R.id.comment);

        if (!StringUtil.isEmpty(comment.avatar)) {
            ImageLoader.load(context, avatar, comment.avatar);
        } else {
            avatar.setImageResource(R.drawable.default_avatar_cricle);
        }
        userName.setText(comment.user_name);
        commentTime.setText(DateUtil.getDateStringFromTZ2MDT(comment.comment_time));
        content.setText(comment.content);
    }
}
